let userInfoList = [
    {
        userId: "userA",
        userSig:
            "eJwtjNEKgjAYRt9l1yFbzk2FLobRRQoRFeFltD-7iWTTTaTo3Rvqd-edA*dLztUpGqAjOVlHlKymjxpahw*csO*hU4vo9etmDGqSM04pzxIus9k4fEOggkmRMSaSmcJosAtcUJ7SsKWCTejCnrZbdQF-jBu3g3hMpbUf24vCFIN6*mvZuPpQ1mN135DfHynmMiQ_",
        name: "姓名1",
        roomId: null,
        headImg: "头像",
        sysType: "1", //设备系统类型
        onTime: "00:10:30", //在线时长
        userType: "1",//用户类型，1是主持人，2是讲者，3是观众
        isMasterUser: true, //是否是主持人
        isMasterSpeech: false, //是否是主讲
        weChatName: "微信名",
        work: "主治医师", //工作岗位
        company: "公司", //公司
        video: true, //是否开启视频
        audio: true, //是否开启音频
    },

    {
        userId: "user_5823172",
        userSig:
            "eJwtjNEKgjAYRt9l1yHbmm4KXRSlmYNADaWbiPyNnzJELcTo3Rvqd-edA*dLUp1YH2iIR7hFyWL8WMCrwxJH-G6hudiKL5nks2*Lx7WusSAeE5QK1xbSnUyHFRjqMOm4TFE*UehrbAx3qFDUbK7g3eSTIc*2t2DPjxtxBggG7cdhGgVVqP0Di3iZxzvdV095Wq-I7w8w-zI3",

        roomId: null,
        name: "姓名2",
        headImg: "头像",
        sysType: "1", //设备系统类型
        onTime: "00:10:30", //在线时长
        userType: "2",
        isMasterUser: false, //是否是主持人
        isMasterSpeech: false, //是否是主讲
        weChatName: "微信名",
        work: "主治医师", //工作岗位
        company: "公司", //公司
        video: true, //是否开启视频
        audio: true, //是否开启音频
    },
    {
        userId: "user_5823173",
        userSig:
            "eJwtjMsKwjAUBf8lW6UkbZKmBReC0oVBxUe3IuRGbrUPmyoV8d8Nbc-uzMB8yUkfgze0JCVhQMl8*Gig6tDigF8O2otQYcTiaPLO3K9Ng4akjFPKE8HjZDQdluCpZLFMBJNipNA32HouKVfUb6rgzeeLrMZc1fst2-Q6KtVZ58b2B3Cz4pHvbPWETFeftVuu6gX5-QFQtzOz",

        roomId: null,
        name: "姓名3",
        headImg: "头像",
        sysType: "1", //设备系统类型
        onTime: "00:10:30", //在线时长
        userType: "2",
        isMasterUser: false, //是否是主持人
        isMasterSpeech: false, //是否是主讲
        weChatName: "微信名",
        work: "主治医师", //工作岗位
        company: "公司", //公司
        video: true, //是否开启视频
        audio: true, //是否开启音频
    },
    {
        userId: "user_5823174",
        userSig:
            "eJwtjF0LgjAYRv-LrsM2e*c2oYughNQLw111E6Ez3kQbuj4o*u*Z*tw958D5EJ3m3sN0JCS*R8li-Fia1mGFI773pjtx6a*YgNn3ZX22FksSMqAUFAehJuOwMQMNmAgUZ5JP1LwsdgMPKEg6bK7g5Z*vk*c*uoEqEs13B7eJhTmmWlzjKMnqqnlv2x4yP18WsCbfHz9fMog_",
        roomId: null,
        name: "姓名3",
        headImg: "头像",
        sysType: "", //设备系统类型
        onTime: "00:10:30", //在线时长
        userType: "2",
        connectSpeechStatus: 1, //连麦状态,1,未发起连麦,2发起了连麦,3连麦中
        isMasterSpeech: false, //是否是主讲
        weChatName: "微信名",
        work: "主治医师", //工作岗位
        company: "公司", //公司
        video: true, //是否开启视频
        audio: true, //是否开启音频
    },
    {
        userId: "user_5823175",
        userSig:
            "eJyrVgrxCdYrSy1SslIy0jNQ0gHzM1NS80oy0zLBwqXFqUXxphZGxobmplD54pTsxIKCzBQlK0MTAwMTS1MTc0uITElmbipQ1MzQ3MzSFKgFIppaUZBZBBQ3MzCxMAACqCmZ6UDjw0IqciL909JzC3NMk4qcDD3yyqNc-E3z0rJMPVJzA6vCHFOSy1OMclwrXW2VagFeiDPk",

        roomId: null,
        name: "姓名4",
        headImg: "头像",
        sysType: "", //设备系统类型
        userType: "3",
        onTime: "00:10:30", //在线时长
        isInteraction: false, //是否是互动
        connectSpeechStatus: 1, //连麦状态,1,未发起连麦,2发起了连麦,3连麦中
        isMasterSpeech: false, //是否是主讲
        weChatName: "微信名",
        work: "主治医师", //工作岗位
        company: "公司", //公司
        video: false, //是否开启视频
        audio: false, //是否开启音频
    },
    {
        userId: "user_5823176",
        userSig:
            "eJyrVgrxCdYrSy1SslIy0jNQ0gHzM1NS80oy0zLBwqXFqUXxphZGxobmZlD54pTsxIKCzBQlK0MTAwMTS1MTc0uITElmbipQ1Ayo1tLUyMwYIppaUZBZBBQ3MzCxMAACqCmZ6UDjfYMck4MtEs1KAisNTfzztV0KvZKyihLLfJKKgsuywoLDk0OcyhJNU52rXG2VagFHuzNk",

        roomId: null,
        name: "姓名5",
        headImg: "头像",
        sysType: "", //设备系统类型
        onTime: "00:10:30", //在线时长
        userType: "3",
        isInteraction: false, //是否是互动
        connectSpeechStatus: 1, //连麦状态,1,未发起连麦,2发起了连麦,3连麦中
        isMasterSpeech: false, //是否是主讲
        weChatName: "微信名",
        work: "主治医师", //工作岗位
        company: "公司", //公司
        video: false, //是否开启视频
        audio: false, //是否开启音频
    },
    // //分享占用
    // {
    //   userId: "user_5823177",
    //   userSig:
    //     "eJyrVgrxCdYrSy1SslIy0jNQ0gHzM1NS80oy0zLBwqXFqUXxphZGxobm5lD54pTsxIKCzBQlK0MTAwMTS1MTc0uITElmbipQ1MzQzNzI3MTCECKaWlGQWQQUNzMwsTAwgJqRmQ40vKCqIlg7x9-fu7jCszwnudQzJcopMsXE0zvUwNg5vDzAMSukyizT3SvKLNBWqRYAAnwy0w__",
    //   isUse: false,
    // },
    // //白板流占用
    // {
    //   userId: "user_5823178",
    //   userSig:
    //     "eJwtzEsLgkAUhuH-MttCztjcDFroQgi6YoS7sOYkR1FEpzCi-56oy*-54P2yyy7x3tiyNfM9YMtxk8Xa0ZNGfnXY3qTxV1yb*e9smTUNWbbmAkAEUuhgehxVOKjiSvtacjMp9g21gysQBmBuUD7Eq-29z1XsTtGjyDOpF3WU2Fh0YXotXcEP6RkQw4-gx*2G-f7wtTJO",
    //   isUse: false,
    // },
];

const getUserInfo = function (req, res) {
    console.log('获取用户信息', req.query.userId)
    let userId = req.query.userId;
    let data = null;
    if (userId) {
        for (let i in userInfoList) {
            if (userInfoList[i].userId == userId) {
                data = userInfoList[i];
                break;
            }
        }
    }
    res.json(data);
};
// 用户加入房间
const userJoinRoom = function (req, res) {
    console.log('用户加入房间', req.body);
    let body = req.body;
    let userId = body.userId;
    let roomId = body.roomId;
    let data = null;
    if (userId) {
        for (let i in userInfoList) {
            if (userInfoList[i].userId == userId) {
                userInfoList[i]['roomId'] = roomId;
                data = userInfoList[i];
                break;
            }
        }
    }
    res.json(data);
}
// 用户离开房间
const userLeaveRoom = function (req, res) {
    console.log('用户离开房间', req.body);
    let body = req.body;
    let userId = body.userId;
    let data = null;
    if (userId) {
        for (let i in userInfoList) {
            if (userInfoList[i].userId == userId) {
                userInfoList[i]['roomId'] = null;
                data = userInfoList[i];
                break;
            }
        }
    }
    res.json(data);
}
// 获取房间内的用户列表
const getRoomUserList = function (req, res) {
    console.log('获取房间内的用户列表', req.body);
    let body = req.body;
    let roomId = body.roomId;
    let data = [];
    if (roomId) {
        for (let i in userInfoList) {
            if (userInfoList[i].roomId == roomId) {
                data.push(userInfoList[i]);
            }
        }
    }
    res.json(data);
}
// 修改用户信息
const updateUserInfo = function (req, res) {

    console.log('修改用户信息', req.body);
    let userId = req.body.userId;
    let userInfo = req.body.userInfo;
    let data = {};
    if (userId) {
        for (let i in userInfoList) {
            if (userInfoList[i].userId == userId) {
                Object.assign(data, userInfoList[i], userInfo);
                userInfoList[i] = data;
                break;
            }
        }
    }
    res.json(data);
}
// 用户申请主讲
// const 
module.exports = {
    getUserInfo,
    userJoinRoom,
    userLeaveRoom,
    getRoomUserList,
    updateUserInfo
}